package anntest;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class TestOptAnnotation {
    public static void main(String[] args) throws NoSuchMethodException, NoSuchFieldException {
        TestClass t = new TestClass();
        System.out.println("-----------MyAnnotation4Classע---------");
        MyAnnotationForClass an4clazz = t.getClass().getAnnotation(MyAnnotationForClass.class);
        System.out.println(an4clazz.msg());
        System.out.println("-----------MyAnnotation4Methodע---------");
        Method method = t.getClass().getMethod("testMethod", new Class[0]);
        MyAnnotationForMethod an4method = method.getAnnotation(MyAnnotationForMethod.class);
        System.out.println(an4method.msg1());
        System.out.println(an4method.msg2());
        System.out.println("-----------MyAnnotation4Fieldע---------");
        Field field = t.getClass().getDeclaredField("testfield");
        MyAnnotationForField an4field = field.getAnnotation(MyAnnotationForField.class);
        System.out.println(an4field.commont());
        System.out.println(an4field.request());
    }
}

